use std::string::ToString;
use ansi_term::{Style,ANSIString,ANSIStrings,ANSIByteStrings};
use ansi_term::Colour::{Fixed,Red,Blue,Yellow,Cyan,RGB,Green};

fn main() {
    let ansi_string = Red.paint("a red string");
    println!("This is in red:{}",ansi_string.to_string());
   
    println!("How about some {} and {}?",
    Style::new().bold().paint("bold"),
    Style::new().underline().paint("underline"));

    println!("Demonstrating {} and {}!",
    Blue.bold().paint("blue bold"),
    Yellow.underline().paint("yellow underline"));

    println!("Yellow on blue:{}",Blue.on(Yellow).paint("wow!"));

    println!("Yellow on blue:{}",Style::new().on(Blue).fg(Yellow).paint("yow!"));

    println!("Also Yellow on blue:{}",Cyan.on(Blue).fg(Yellow).paint("zow!"));

    println!("{}",Red.normal().paint("yet another red string"));

    println!("{}",Style::default().paint("a completely regular string"));

    println!("{}", Fixed(134).paint("A sort of light purple"));

    println!("{}",Fixed(221).on(Fixed(124)).paint(" Mustard in the ketchup "));

    println!("{}",RGB(70,130,180).paint("Steel blue"));

    let some_value = format!("{:b}",42);
    let strings:&[ANSIString<'static>] = &[
        Red.paint("["),
        Red.bold().paint(some_value),
        Red.paint("]")
    ];
    println!("Value:{}",ANSIStrings(strings));

    Green.paint("user data".as_bytes()).write_to(&mut std::io::stdout()).unwrap();

    ANSIByteStrings(&[
        Green.paint("user data 1\n".as_bytes()),
        Green.bold().paint("user data 2\n".as_bytes())
    ]).write_to(&mut std::io::stdout()).unwrap();
}
